#ifndef __FRAME_H__
#define __FRAME_H__

#include "windoze.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MAX_TOUCH_IN_FRAME			(16)

#define FRM_TITLE_BAR_HEIGHT		(26)
#define FRM_TASK_BAR_HEIGHT			(36)

#define FRM_BTN_BACK				(0x01)
#define FRM_BTN_OPTION				(0x02)
#define FRM_BTN_SCROLL				(0x08) // 0x01:SCROLL_UP   0x02:SCROLL_DN
#define FRM_BTN_HELP				(0x10)

#define FRM_BTN_SCROLL_UP			(0x01)
#define FRM_BTN_SCROLL_DN			(0x02)

#define FRM_NO_TASK					(0x40)
#define FRM_NO_TITLE				(0x80)

typedef struct _TTouchInfo
{
	int				ID;		// touch area IDs
	TRect			rect;	// touch area rectangles
}TTouchInfo;

typedef struct _TFrame
{
	int				win_cnt;						// how many windoze in frame
	int				focus;							// index of focused windoze
	TCanvas*		pCanvas;						// canvas to be drawn
	TWindoze*		pWin[MAX_WINDOZE_IN_FRAME];		// windoze in frame
	BOOL			visible[MAX_WINDOZE_IN_FRAME];
	BOOL			enable[MAX_WINDOZE_IN_FRAME];

	char			title[MAX_WIN_TEXT_LEN];		// title text of frame
	unsigned char	style;							// buttons in task bar
	int				touch_cnt;						// how many touch area in frame
	TTouchInfo		touch[MAX_TOUCH_IN_FRAME];
	int				scroll_idx;
	///out
	void			(*pEnter)(int idx);
	void			(*pDraw)(TCanvas *pCanvas);
}TFrame;
TCanvas* frm_get_canvas();
BOOL frm_Create(TFrame* pFrame, unsigned char style, char* pTitle);
BOOL frm_AddWindoze(TFrame* pFrame, TWindoze* pWin);
int frm_Input(TFrame* pFrame, UInt32 code);
void frm_Draw(TFrame* pFrame);

void frm_draw_bk(TFrame *pFrame);
void frm_draw_title(TFrame *pFrame);
void frm_draw_task(TFrame *pFrame);
BOOL frm_add_touch(TFrame *pFrame, TRect rect, int ID);
BOOL frm_remove_touch(TFrame *pFrame, int ID);

TRect frm_get_touch_rect(TFrame *pFrame, int ID);

////
BOOL frm_SetWinEnable( TFrame* pFrame, TWindoze* pWin, BOOL bEnable );
BOOL frm_GetWinEnable( TFrame* pFrame, TWindoze* pWin );

BOOL frm_SetWinVisible( TFrame* pFrame, TWindoze* pWin, BOOL bVisible );
BOOL frm_GetWinVisible( TFrame* pFrame, TWindoze* pWin );

BOOL frm_SetWinFocus( TFrame* pFrame, TWindoze* pWin );

BOOL frm_SetScrollWindoze( TFrame* pFrame, TWindoze* pWin );
BOOL frm_Scroll_UP( TFrame* pFrame );
BOOL frm_Scroll_DN( TFrame* pFrame );
#ifdef __cplusplus
}
#endif

#endif // __FRAME_H__
